<template>
    <div class="AssetsInfoDetial">
        <!-- 挂牌车资产信息 二手车资产信息 -->
        <Form ref="formData" :model="formData" :label-width="120" disabled>
            <Card>
                <div class="common_br">
                    <h2 class="common_title">
                        资产信息
                        <span class="common_title_more">
                        <span>{{contractNo}}</span>
                    </span>
                    </h2>
                    <div class="common_content">
                        <Row>
                            <Col span="8">
                                <FormItem label="VIN号" prop="carVin">
                                    <Input v-model="formData.carVin"/>
                                </FormItem>
                            </Col>

                            <Col span="8">
                                <FormItem label="品牌" prop="brandName">
                                    <Input v-model="formData.brandName"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="车型" prop="modelName">
                                    <Input v-model="formData.modelName"/>
                                </FormItem>
                            </Col>
                            <!-- </Row> -->
                            <!-- <Row> -->
                            <Col span="8">
                                <FormItem label="款式" prop="styleName">
                                    <Input v-model="formData.styleName"/>
                                </FormItem>
                            </Col>
                            <!-- </Row> -->
                            <!-- <Row> -->
                            <Col span="8">
                                <FormItem label="车身级别" prop="carBodyClass">
                                    <Input v-model="formData.carBodyClass"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="车辆颜色" prop="carColor">
                                    <Input v-model="formData.carColor"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="发动机号" prop="engineNo">
                                    <Input v-model="formData.engineNo"/>
                                </FormItem>
                            </Col>
                            <!--                        </Row>-->
                            <!--                        <Row>-->
                            <Col span="8">
                                <FormItem label="燃油种类" prop="fuelType">
                                    <Select v-model="formData.fuelType" placeholder="">
                                        <Option :value="item.value" v-for="(item,index) in dataDict.fuelTypeDict"
                                                :key="index">{{item.title}}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="排量" prop="carDisplacement">
                                    <Input v-model="formData.carDisplacement"/>
                                    <span class="ml10">T/L</span>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="变速器" prop="carTransmission">
                                    <Select v-model="formData.carTransmission" placeholder="">
                                        <Option :value="item.value" v-for="(item,index) in dataDict.transmissionDict"
                                                :key="index">{{item.title}}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <!--                        </Row>-->
                            <!--                        <Row>-->
                            <Col span="8">
                                <FormItem label="使用性质" prop="carFunction">
                                    <Select v-model="formData.carFunction" placeholder="">
                                        <Option :value="item.value" v-for="(item,index) in dataDict.carUseDict"
                                                :key="index">{{item.title}}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="核定载客" prop="totalPassenger">
                                    <InputNumber v-model="formData.totalPassenger"></InputNumber>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="表显里程(公里)" prop="mileage">
                                    <Input v-model="formData.mileage"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="车辆型号" prop="fullModelNum">
                                    <Input v-model="formData.fullModelNum"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="新车购车价格" prop="guidePrice">
                                    <Input v-model="formData.guidePrice"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="二手车销售价格" prop="secondSalePrice">
                                    <Input v-model="formData.secondSalePrice"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="评估价格" prop="evaluatingPrice">
                                    <Input v-model="formData.evaluatingPrice"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="所有人" prop="carBelongs">
                                    <Input v-model="formData.carBelongs"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="所有人证件" prop="belongsCertNo">
                                    <Input v-model="formData.belongsCertNo"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <PlaceCascade
                                    label="上牌地址"
                                    value="licenseAddress"
                                    :form="formData"
                                    :isDetailAddress="false"
                                    :isDisabled="false"
                                    :location="initLoadData"
                                />
                            </Col>
                            <Col span="8">
                                <PlaceCascade
                                    label="购买地点"
                                    value="ProvinceAddress"
                                    :form="formData"
                                    :isDetailAddress="false"
                                    :isDisabled="false"
                                    :location="initLoadData"
                                />
                            </Col>
                        </Row>
                        <Row v-if="isOwnerAdress">
                            <Col span="8">
                                <FormItem label="所有人住址" prop="belongsAddress">
                                    <Input v-model="formData.belongsAddress"/>
                                </FormItem>
                            </Col>
                        </Row>
                    </div>
                </div>
            </Card>
            <Card>
                <div class="common_br">
                    <h2 class="common_title">车辆手续信息</h2>
                    <div class="common_content">
                        <Row>
                            <Col span="8">
                                <FormItem label="车牌号" prop="licensePlate">
                                    <Input v-model="formData.licensePlate"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="评估师" prop="carAppraiser">
                                    <Input v-model="formData.carAppraiser"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="车商姓名" prop="dealerName">
                                    <Input v-model="formData.dealerName"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="车商联系电话" prop="dealerPhone">
                                    <Input v-model="formData.dealerPhone"/>
                                </FormItem>
                            </Col>
                            <Col span="8">
                            </Col>
                            <Col span="8">
                                <FormItem label="首次登记日期" prop="firstLandingDate">
                                    <DatePicker type="date" v-model="formData.firstLandingDate"></DatePicker>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="一年内过户次数" prop="yearTransNum">
                                    <InputNumber v-model="formData.yearTransNum"></InputNumber>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="总过户次数" prop="transNums">
                                    <InputNumber v-model="formData.transNums"></InputNumber>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <FormItem label="是否循环过户" prop="isCirTrans">
                                    <Select v-model="formData.isCirTrans" placeholder="">
                                        <Option :value="item.value" v-for="(item,index) in dataDict.yesOrNoDict"
                                                :key="index">{{item.title}}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <Col span="8">
                                <PlaceCascade
                                    label="注册地点"
                                    value="registAddress"
                                    :form="formData"
                                    :isDetailAddress="false"
                                    :isDisabled="false"
                                    :location="initLoadData"
                                />
                            </Col>
                            <Col span="8">
                                <PlaceCascade
                                    label="上牌地点"
                                    value="licenseAddress"
                                    :form="formData"
                                    :isDetailAddress="false"
                                    :isDisabled="false"
                                    :location="initLoadData"
                                />
                            </Col>
                            <Col span="8">
                                <PlaceCascade
                                    label="车商联系地址"
                                    value="dealerAddress"
                                    :form="formData"
                                    :isDetailAddress="false"
                                    :isDisabled="false"
                                    :location="initLoadData"
                                />
                            </Col>
                        </Row>
                        <Row>
                            <Col span="8">
                                <FormItem label="是否抵押" prop="isMortgage">
                                    <Select v-model="formData.isMortgage" placeholder="">
                                        <Option :value="item.value" v-for="(item,index) in dataDict.yesOrNoDict"
                                                :key="index">{{item.title}}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                        </Row>
                    </div>
                </div>
            </Card>
        </Form>
    </div>
</template>
<script>
    import {getDictDataList} from "_p/basic/assets/contract/js/utils";
    import {carDetailsList} from "_p/basic/api/contract/contract-detail-inquiry";
    import PlaceCascade from "_p/basic/pages/contract/common/PlaceCascade";
    import {getLocation} from "_p/basic/api/contract/common/common";

    export default {
        name: "AssetsInfoDetial",
        components: {
            PlaceCascade
        },
        data() {
            return {
                totalLevel: 2,
                //collcapital:"capital",
                collproce: "proce",

                registLabel: "注册地点",
                registValue: "registLocation",

                dealerLabel: "车商联系地址",
                dealerValue: "dealerLocation",

                licenseLabel: "上牌地点",
                licenseValue: "licenseLocation",
                // purchaseLabel:"购买地点",
                // purchaseValue:"purchaseLocation",
                initLoadData: [],
                isOwnerAdress: false,
                // 燃油种类
                fuelTypeList: [],
                // 是否
                judgeList: [],
                //变速器
                transmissionList: [],
                vinDataModel: false,
                vinColumns: [
                    {
                        type: "index",
                        title: "序号"
                    },
                    {
                        title: "品牌",
                        key: "maker"
                    },
                    {
                        title: "车型",
                        key: "modelName"
                    },
                    {
                        title: "款式",
                        key: "carConfig",
                        minWidth: 500
                    },
                    {
                        title: "发动机号",
                        key: "engineNumber"
                    },
                    {
                        title: "车辆价格",
                        key: "modelPrice"
                    }
                ],
                vinList: [],
                carFunctionList: [],
                formData: {
                    ProvinceAddress: [],
                    totalPassenger: "",
                    yearTransNum: "",
                    transNums: "",
                    isCirTrans: "",
                    isMortgage: "",
                    dealerAddress: [],
                    licenseAddress: [],
                    registAddress: []
                },
                location: [],
                isShowDetails: false,

                pageParams: null,
                contractNo: "",
                openPanel: [],
                // 放款模式(loanModel) 变更类型  变更主体(PersonRoleType)
                dictArr: ["loanModel", "PersonRoleType", "yesOrNo", "carUse", "fuelType", "transmission"],
                dataDict: {}
            };
        },
        props: {},
        created() {
            this.getParams();
        },
        mounted() {
            this.init();
        },
        methods: {
            init() {
                this.getDictDataList(); // 数据字典
                this.getDetial();
                this.getInitData();
            },
            getInitData() {
                let param = {
                    level: "1",
                    upperCode: "1"
                };
                getLocation(param).then(res => {
                    if (res.code == "0000") {
                        res.data.forEach(item => {
                            // 表明是否是父节点
                            if (item.isParent) {
                                item.loading = false;
                                item.children = [];
                            }
                        });
                    }
                    this.initLoadData.push(...res.data);
                });
            },
            loadData(item, callback) {
                item.loading = true;
                getLocation({upperCode: item.value}).then(res => {
                    if (res.code === "0000") {
                        res.data.forEach(function (item) {
                            if (item.isParent) {
                                item.loading = false;
                                item.children = [];
                            }
                        });
                        item.children = res.data;
                        item.loading = false;
                        callback();
                    }
                });
            },
            // 获取初始数据
            getParams() {
                const pageParams = this.afs.getPageParams(this);
                console.log("初始数据:::::::", pageParams);
                this.pageParams = pageParams;
                this.contractNo = pageParams.contractNo;
            },
            // 数据字典
            getDictDataList() {
                getDictDataList(this.dictArr).then(res => {
                    console.log("getDictDataList(this.dicttArr)", res);
                    this.dataDict = res;
                });
            },
            // 请求数据
            getDetial() {
                carDetailsList(this.contractNo).then(res => {
                    if (res.code === "0000") {
                        let d = {};
                        Array.isArray(res.data) &&
                        res.data.forEach(ele => {
                            Object.assign(d, ele);
                        });
                        d.ProvinceAddress = [d.purchaseProvince, d.purchaseCity];
                        d.licenseAddress = [d.licenseProvince, d.licenseCity];
                        d.dealerAddress = [d.dealerProvince, d.dealerCity, d.dealerCounty, d.dealerStreet];//车商联系地址
                        d.registAddress = [d.registProvince, d.registCity];//注册地点
                        this.formData = Object.assign({}, this.formData, d);
                    }
                });
            },
            back() {
                //关闭页面
                this.afs.closeTab(this);
            },
            showSpin() {
                this.spinShow = true;
            },
            closeSpin() {
                this.spinShow = false;
            },
            changChildrenData(refDom, name, value) {
                console.log(this.$refs[refDom], "this.$refs[name]");
                if (this.$refs[refDom]) {
                    this.$refs[refDom][name] = value;
                }
            }
        }
    };
</script>
<style lang="less">
    @import "../../../../../../styles/common/form.less";

    .common_title_more {
        padding-left: 10px;
        font-size: 12px;

        span {
            padding-left: 10px;
        }
    }
</style>
